//Creado por Eduardo Morales el 21 de noviembre de 2006 
import javax.swing.*;
import java.beans.*;
import java.util.Observer;
import java.util.Observable;


public class principal implements Observer {
 //declaracion de las clases
  AgregarPrestatario agregarP;
 //AnularMultas anularM;
  BuscarMaterial buscarM;
  BuscarPrestatario buscarP;
  DevolverMaterial devolverM;
  EliminarPrestatario eliminarP;
  EliminarVolumen eliminarV;
  FichaMaterial fichaM;
  FichaPrestatario fichaP;
  IngresarNuevoMaterial ingresarM;
  ListarMultas listarM;
  ListarPrestamos listarP;
  PrestarMaterial prestarM;
  RenovarVolumen renovarV;
  ReservarMaterial reservarM;
  Login loginP;
  Configuraciones configuraciones;
  VerificadorPrestamos buscaAtrasos;
  desMultador desmulta;
 //fin declaracion clases

 // Variables 
 	JFrame ventanaPrincipal;
 	
 	 private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton9;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
  
  String ventanaObservada;
  // fin variables        

    public principal() {
        levantaVista();
        levantaLogin();
        buscaAtrasos=new VerificadorPrestamos(); 
        desmulta=new desMultador();     
        
    }
    
                         
//*************Vista************ 
    private void levantaVista() {
    	
    	ventanaPrincipal = new JFrame();
        jPanel1 = new javax.swing.JPanel();
        jButton9 = new javax.swing.JButton();
        jButton1 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();

        ventanaPrincipal.setTitle("Venta Principal");
        ventanaPrincipal.setResizable(false);
        ImageIcon icon = new ImageIcon("images/administrator1_16x16.gif");
        jButton9.setIcon(icon);
        jButton9.setText("Prestatario");
        jButton9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton9.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton9.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });
		ImageIcon icon1 = new ImageIcon("images/report2_16x16.gif");
        jButton1.setIcon(icon1);
        jButton1.setText("Material");
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        
        ImageIcon icon2 = new ImageIcon("images/zoom_16x16.gif");
        jButton11.setIcon(icon2);
        jButton11.setText("Buscar");
        jButton11.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton11.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton11.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton11ActionPerformed(evt);
            }
        });

       
        ImageIcon icon3 = new ImageIcon("images/settings1_16x16.gif");
        jButton12.setIcon(icon3);
        jButton12.setText("Configuraci\u00f3n");
        jButton12.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton12.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton12.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton12ActionPerformed(evt);
            }
        });

        
        ImageIcon icon4 = new ImageIcon("images/ordered_list_16x16.gif");
        jButton5.setIcon(icon4);
        jButton5.setText("Multas en curso");
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        
        ImageIcon icon5 = new ImageIcon("images/script_(start)_16x16.gif");
        jButton6.setIcon(icon5);
        jButton6.setText("Prestamos en curso");
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jButton9)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton11)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton12)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton5)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jButton6)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton1)
                        .add(jButton9))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(jButton12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(jButton6, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 46, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jButton11)))
        );

        
        ImageIcon icon6 = new ImageIcon("images/exit.png");
        jButton2.setIcon(icon6);
        jButton2.setText("Salir");
		jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });





        jLabel1.setFont(new java.awt.Font("Arial", 1, 14));
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Administracion de inventario y prestamo de materiales ");

        jLabel2.setFont(new java.awt.Font("Arial", 1, 14));
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Seleccione lo que desea hacer");

        org.jdesktop.layout.GroupLayout jFrame1Layout = new org.jdesktop.layout.GroupLayout(ventanaPrincipal.getContentPane());
        ventanaPrincipal.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                        .add(jFrame1Layout.createSequentialGroup()
                            .add(jLabel2, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 604, Short.MAX_VALUE)
                            .addContainerGap())
                        .add(jFrame1Layout.createSequentialGroup()
                            .add(jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jButton2)
                                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .addContainerGap()))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jFrame1Layout.createSequentialGroup()
                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 604, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap())))
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel1)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jLabel2)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 300, Short.MAX_VALUE)
                .add(jButton2)
                .addContainerGap())
        );
        ventanaPrincipal.pack();
    }


//**********Controlador*********


//Boton Configuraciones
    private void jButton12ActionPerformed(java.awt.event.ActionEvent evt) {
	ventanaObservada="configuraciones";
		configuraciones=new Configuraciones();
		configuraciones.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
/*
//Boton BuscarPrestatario
    private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="buscarPrestatario";
		buscarP=new BuscarPrestatario();
		buscarP.addObserver(this);
		ventanaPrincipal.setVisible(false);

    }
  */
  
  //Boton Salir
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
	System.exit(1);
    }
  
//Boton Eliminar Volumen
    private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="eliminarVolumen";
		eliminarV=new EliminarVolumen();
		eliminarV.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
//Boton Eliminar Prestatario 
    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="eliminarPrestatario";
		eliminarP=new EliminarPrestatario();
		eliminarP.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
//Boton Agregar Material 
    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="agregarMaterial";
		ingresarM=new IngresarNuevoMaterial();
		ingresarM.addObserver(this);
		ventanaPrincipal.setVisible(false);
   	}
    
//Boton Agregar pestatario
    private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {
	ventanaObservada="agregarPrestatario";
	agregarP=new AgregarPrestatario();
	agregarP.addObserver(this);
	ventanaPrincipal.setVisible(false);
    }
    
//Boton Ver multas en curso 
    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
	ventanaObservada="listarMultas";
	listarM=new ListarMultas();
	listarM.addObserver(this);
	ventanaPrincipal.setVisible(false);
    }
    
//Boton Ver Prestamos en curso 
    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="listarPrestamos";
		listarP=new ListarPrestamos();
		listarP.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
//Boton Renovar Material
    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="renovarVolumen";
		renovarV=new RenovarVolumen();
		renovarV.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
//Boton Buscar Material
    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
    ventanaObservada="buscarMaterial";
	buscarM=new BuscarMaterial();
	buscarM.addObserver(this);
	ventanaPrincipal.setVisible(false);
    }
    
//Boton Devolver Material
    private void jButton13ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="devolverrMaterial";
		devolverM=new DevolverMaterial();
		devolverM.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
//Boton Prestar Material
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
		ventanaObservada="prestarMaterial";
		prestarM=new PrestarMaterial();
		prestarM.addObserver(this);
		ventanaPrincipal.setVisible(false);
    }
    
    
//Boton Buscar

	private void jButton11ActionPerformed(java.awt.event.ActionEvent evt) { 
		ventanaObservada="buscarPrestatario";
		buscarP=new BuscarPrestatario();
		buscarP.addObserver(this);
		ventanaPrincipal.setVisible(false);
	}  
    
// Levanta el login
	private void levantaLogin(){
		ventanaObservada= "login";
		loginP = new Login();
		loginP.addObserver(this);
		
	
	}


public void update( Observable obs,Object obj ) {
      System.out.println("lalala");
      
      //login
    	
      	
      	ventanaPrincipal.setVisible(true);
   		//buscaAtrasos=new VerificadorPrestamos();
      
      
      }

public static void main(String args[]){
	principal i=new principal();
}


}